package tree.easy;

import tree.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * 剑指 Offer 54. 二叉搜索树的第k大节点
 */
public class kthLargest {
    int k,res;
    public int kthLargest(TreeNode root, int k) {
        this.k = k;
        help(root);
        return res;
    }

    public void help(TreeNode root) {
        if (root == null) {
            return;
        }
        help(root.right);
        if (--k == 0) {
            res = root.val;
        }
        help(root.left);
    }

}
